/*
 *   Copyright 2009 Sukharev Eduard <kraplax@mail.ru>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef UPDATESWIDGET_HDR
#define UPDATESWIDGET_HDR

#include <QGraphicsLinearLayout>
#include <QString>
#include <QHttp>
#include <QBuffer>
#include <plasma/dialog.h>
#include <Plasma/Frame>
#include <Plasma/TextBrowser>
#include <Plasma/PushButton>
#include <KTextBrowser>
typedef enum {Mixed, Posts, Comments} WidgetType;

class UpdatesWidget : public Plasma::Frame
{
    Q_OBJECT
private:
    QGraphicsLinearLayout * m_genLayout;
    QString m_colors[2];
    Plasma::TextBrowser * m_browser;
    Plasma::PushButton * m_btnUpdateContent;
    QHttp * m_httpConnection;
    QBuffer m_buffer;
    int m_maxFetched;
    WidgetType m_widgetType;
    
    static QString colorToString(const QColor & color);

private slots:
    void reConfigure();
    void updateContent();
    void requestUpdate();
    void init();
    void httpDone(bool);

public:
//    UpdatesWidget();
    UpdatesWidget(QWidget *parent = 0, Qt::WindowFlags = 0, WidgetType type = Mixed);
    void setContentType(WidgetType type);
    void setMaxFetched(int maxFetched);
};

#endif
